package com.itheima.demo;

import com.itheima.config.SpringConfig;
import com.itheima.pojo.UserInfo;
import com.itheima.service.UserInfoService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class Demo {

    public static void main(String[] args) {
        //1. 创建spring IOC容器
        ApplicationContext ac = new AnnotationConfigApplicationContext(SpringConfig.class);
        //2. 获取bean对象
        UserInfoService userInfoService = ac.getBean(UserInfoService.class);
        //3. 调用service层
        List<UserInfo> all = userInfoService.findAll();
        //4. 输出打印
        System.out.println(all);
    }
}
